package com.maomao.test.io;

import java.io.*;

/**
 *
 * @author admin
 * @date 2018/4/23
 */
public class StoringAndRecoveringData {
    public static void main(String[] args) throws IOException {
        DataOutputStream out = new DataOutputStream(
                new BufferedOutputStream(new FileOutputStream("C:\\Users\\admin\\Desktop\\selfFile\\test2.txt"))
        );
        out.writeDouble(3.1415626);
        out.writeUTF("That was pi");
        out.writeDouble(1.41134);
        out.writeUTF("Square root of 2");
        out.close();
        DataInputStream in = new DataInputStream(
                new BufferedInputStream(new FileInputStream("C:\\Users\\admin\\Desktop\\selfFile\\test2.txt"))
        );
        System.out.println(in.readDouble());
        System.out.println(in.readUTF());
        System.out.println(in.readDouble());
        System.out.println(in.readUTF());
    }
}
